<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:89:"D:\phpStudy\PHPTutorial\WWW\dk.eatchickengame.com/application/index\view\index\money.html";i:1532929083;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <link rel="stylesheet" type="text/css" href="__FRONT__/dist/lib/weui.min.css">
    <link rel="stylesheet" type="text/css" href="__FRONT__/dist/css/jquery-weui.min.css">
    <link rel="stylesheet" type="text/css" href="__FRONT__/dist/demos/css/demos.css">
</head>
<body ontouchstart>
    <div class="weui-tab">
        <div class="weui-navbar">
            <a class="weui-navbar__item weui-bar__item--on" href="#tab1">
                申请提现
            </a>

            <a class="weui-navbar__item" href="#tab2">
                资金流水
            </a>
        </div>
        <div class="weui-tab__bd">

            <div id="tab1" class="weui-tab__bd-item weui-tab__bd-item--active">
                <div class="weui-cells weui-cells_form" style="margin-top: -1px;">
                    <div class="weui-cell">
                        <div class="weui-cell__hd"><label class="weui-label">我的余额</label></div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="text"  placeholder="<?php echo $userinfo['balance']; ?>" disabled>
                        </div>
                    </div>

                    <div class="weui-cell">
                        <div class="weui-cell__hd"><label class="weui-label">支付方式</label></div>
                        <div class="weui-cell__bd">
                            <input type="radio" id="alipay" value="1" name="pay" checked><label for="alipay" style="margin-left: 10px;">支付宝</label>
                            
                            <input type="radio" id="wxpay"  value="2" name="pay"  style="margin-left: 15px;"><label for="wxpay"  style="margin-left: 10px;">微信</label>
                        </div>
                    </div>

                    <div id="pay1" style="display: none;">
                        <div class="weui-cell">
                            <div class="weui-cell__hd"><label class="weui-label">支付宝账户</label></div>
                            <div class="weui-cell__bd">
                                <input class="weui-input aliuser" type="text"  placeholder="请填写支付宝账户" >
                            </div>
                        </div>

                        <div class="weui-cell">
                            <div class="weui-cell__hd"><label class="weui-label">提现金额</label></div>
                            <div class="weui-cell__bd">
                                <input class="weui-input alinum" type="text"  placeholder="请输入提现金额">
                            </div>
                        </div>
                    </div>

                    <div id="pay2"  style="display: none;">
                        <div class="weui-cell">
                            <div class="weui-cell__hd"><label class="weui-label">微信账户</label></div>
                            <div class="weui-cell__bd">
                                <input class="weui-input wechatuser" type="text"  placeholder="请填写微信账户" >
                            </div>
                        </div>

                        <div class="weui-cell">
                            <div class="weui-cell__hd"><label class="weui-label">提现金额</label></div>
                            <div class="weui-cell__bd">
                                <input class="weui-input wechatnum" type="text"  placeholder="请输入提现金额">
                            </div>
                        </div>
                    </div>
                </div>
                    <a href="javascript:;" id="tijiao" class="weui-btn weui-btn_primary send" style="margin-top: 10px;">提交</a>
            </div>

            <div id="tab2" class="weui-tab__bd-item">
                <?php foreach($cashlog as $k=>$v): ?>
                <div class="weui-cells" style="margin-top: -1px;">
                    <div class="weui-cell">
                        <div class="weui-cell__hd"></div>
                        <div class="weui-cell__bd">
                            <p class="weui-cells__tips">
                                提现编号:<span><?php echo $v['id']; ?></span>
                            </p>
                            <p class="weui-cells__tips">
                                提现金额:<span class="money"><?php echo $v['money']; ?></span>
                            </p>
                            <p class="weui-cells__tips">
                                提现类型:<span class="type"><?php if($v['type'] == 'ali'): ?>支付宝<?php endif; if($v['type'] == 'wx'): ?>微信<?php endif; ?></span>
                            </p>
                            <p class="weui-cells__tips">
                                提现账户:<span class="accont"><?php echo $v['accont']; ?></span>
                            </p>
                            <div class="weui-cells__title">
                                申请日期:<span class="create_time"><?php echo sign_date($v['create_time']); ?></span>
                            </div>
                        </div>
                        <div class="weui-cells">
                            <span class="status">
                            <?php if($v['status'] == '0'): ?>
                            <button style="background: blue" class="weui-btn weui-btn_mini">待审核</button>
                            <?php endif; if($v['status'] == '1'): ?>
                            <button style="background: green" class="weui-btn weui-btn_mini">通过</button>
                            <?php endif; if($v['status'] == '2'): ?>
                            <button style="background: #ff260f" class="weui-btn weui-btn_mini">拒绝</button>
                            <?php endif; ?>
                            </span>
                        </div>
                    </div>
                </div>
                <?php endforeach; ?>
            </div>
        </div>
    </div>
</body>
</html>
<script src="__FRONT__/dist/lib/jquery-2.1.4.js"></script>
<script src="__FRONT__/dist/lib/fastclick.js"></script>
<script src="__FRONT__/dist/js/jquery-weui.js"></script>

<script type="text/javascript">
    $(function() {
        FastClick.attach(document.body);
    });

    window.onload = function(){
        $("#pay1").css("display","block");
        var radios = document.getElementsByName('pay');
        for(var i=0 ;i< radios.length; i++){
            radios[i].indexs = i + 1;
            radios[i].onchange = function(){
                if(this.checked){
                    document.getElementById("pay1").style.display="none";
                    document.getElementById("pay2").style.display="none";
                    document.getElementById("pay" + this.indexs).style.display="block";
                }
            }
        }
    }

    $(".send").click(function () {

        if($('#alipay').is(':checked')){
            var aliuser = $('.aliuser').val();
            var alinum = $('.alinum').val();
            if(!aliuser || !alinum){
                $.toast('请填写完整信息','cancel');
                return
            }
            var reg = /^[0-9]+.?[0-9]*$/;
            if(!reg.test(alinum)){
                $.toast('提现金额必须为数字','cancel');
                return
            }
            param = {};
            param.accont = aliuser;
            param.money = alinum;
            param.type = 'ali';
            $.post('<?php echo url("cash/cash"); ?>',param,function (res) {
                if(res.code){
                    $.toast(res.msg);
                    setTimeout(function () {
                        location.reload();
                    },2000)
                }else{
                    $.toast(res.msg,'cancel');
                }
            })
        }

        if($('#wxpay').is(':checked')){

            var wechatuser = $('.wechatuser').val();
            var wechatnum = $('.wechatnum').val();
            if(!wechatuser || !wechatnum){
                $.toast('请填写完整信息','cancel');
                return
            }
            var regx = /^[0-9]+.?[0-9]*$/;
            if(!regx.test(wechatnum)){
                $.toast('提现金额必须为数字','cancel');
                return
            }
            param = {};
            param.accont = wechatuser;
            param.money = wechatnum;
            param.type = 'wx';
            $.post('<?php echo url("cash/cash"); ?>',param,function (res) {
                if(res.code){
                    $.toast(res.msg);
                    setTimeout(function () {
                        location.reload();
                    },2000)
                }else{
                    $.toast(res.msg,'cancel');
                }
            })
        }

    });
</script>